// eslint-disable-next-line @typescript-eslint/no-unused-vars

import {
  createStore,
  combineReducers,
  applyMiddleware,
  Middleware,
  Store,
  AnyAction
} from "redux"
import languageReducer from "./language/languageReducer"
import recommendProductsReducer from "./recommendProducts/recommendProductsReducer"
import thunk, { ThunkMiddleware } from "redux-thunk"
import { actionLog } from "./middlewares/actionLog"

const rootReducer = combineReducers({
  language: languageReducer,
  recommendProducts: recommendProductsReducer
})

//1. const store = createStore(languageReducer)
const store = createStore(rootReducer)
//  const store = createStore(rootReducer, applyMiddleware(thunk, actionLog))

export type RootState = ReturnType<typeof rootReducer>
// 显式声明ThunkMiddleware的类型
// const thunkMiddleware: ThunkMiddleware<RootState, AnyAction> = thunk

export default store
